//
//  FQDFeedBaseViewController.h
//  FakeQDaily
//
//  Created by mewxiv on 9/19/16.
//  Copyright © 2016 Xensius. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "FQDFeedCollectionViewCell.h"
@class FQDFeedCellItemProvider;
@class FQDFeedCellItem;

@interface FQDFeedBaseViewController : UIViewController <FQDBaseCellActionDelegate,
                                                         UICollectionViewDelegate,
                                                         UICollectionViewDataSource,
                                                         UICollectionViewDelegateFlowLayout,
                                                         UIScrollViewDelegate>
// 信息流CollectionView
@property (nonatomic, readonly, strong) UICollectionView *feedCollectionView;
// Cell数据供应者
@property (nonatomic, strong) FQDFeedCellItemProvider *provider;
// 信息流列表容器
@property (nonatomic, strong) UIView *feedContentView;
// 是否隐藏RefreshHeader，默认为NO
@property (nonatomic, assign) BOOL disableRefreshHeader;

// 加载新的数据
- (void)loadNewCellItemsWithCompletion:(void (^)(BOOL success))completion;
// 加载更多数据
- (void)loadMoreCellItemsWithCompletion:(void (^)(BOOL success))completion;
// 重新加载
- (void)reloadData;

// 返回需要注册的单元格
- (NSArray *)cellClasses;

// 返回对应信息流数据的单元格的类
- (Class)cellClassForCellItem:(FQDFeedCellItem *)cellItem;
// 返回需要注册的HeaderCell类
- (Class)headerCellClassAtIndexPath:(NSIndexPath *)indexPath inCollectionView:(UICollectionView *)collectionView;
// 返回HeaderCell的个数
- (NSInteger)numberOfHeaderCellsInCollectionView:(UICollectionView *)collectionView;

// 配置信息流单元格
- (void)configureFeedCell:(UICollectionViewCell *)feedCell atIndexPath:(NSIndexPath *)indexPath inCollectionView:(UICollectionView *)collectionView;
- (void)configureHeaderCell:(UICollectionViewCell *)headerCell atIndexPath:(NSIndexPath *)indexPath inCollectionView:(UICollectionView *)collectionView;

// 选择信息流单元格时调用此方法，如果feed类型为FQDFeed，默认使用FQDArticleDetailViewController展示feed对应的文章内容
- (void)didSelectCellItem:(FQDFeedCellItem *)cellItem atIndexPath:(NSIndexPath *)indexPath inCollectionView:(UICollectionView *)collectionView;
// 选择HeaderCell的回调
- (void)didSelectHeaderCellAtIndexPath:(NSIndexPath *)indexPath inCollectionView:(UICollectionView *)collectionView;

// HeaderCell的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForHeaderCellAtIndexPath:(NSIndexPath *)indexPath;
// HeaderCell的边距
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetsForHeaderCellSection:(NSInteger)section;

@end
